local xingshen = fk.CreateSkill {

  name = "joy__xingshen",

  tags = {  },

}



xingshen:addEffect(fk.Damaged, {
  name = "joy__xingshen",
  anim_type = "masochism",
  events = {fk.Damaged},
  on_use = function(self, event, target, player, data)
    local room = player.room
    if table.every(room.alive_players, function(p) return p:getHandcardNum() >= player:getHandcardNum() end) then
      player:drawCards(2, xingshen.name)
    else
      player:drawCards(1, xingshen.name)
    end
    if player.dead or player:getMark("@joy__yanjiao") > 5 then return end
    if table.every(room.alive_players, function(p) return p.hp >= player.hp end) then
      room:addPlayerMark(player, "@joy__yanjiao", player:getMark("@joy__yanjiao") > 3 and 1 or 2)
    else
      room:addPlayerMark(player, "@joy__yanjiao", 1)
    end
  end,
})

return xingshen